<template>
  <el-main>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <!-- <div style=""></div> -->
      <el-form-item>
        <el-select v-model="formInline.region" placeholder="请选择阶梯" clearable>
          <el-option value="第一阶梯" />
          <el-option value="第二阶梯" />
          <el-option value="第三阶梯" />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">
          <el-icon><Search /></el-icon>查询
        </el-button>
      </el-form-item>

      <el-row>
        <el-col :span="2">
          <el-button type="primary" @click="onSubmit"
            ><el-icon><Plus /></el-icon>添加</el-button
          >
        </el-col>
      </el-row>
      <p></p>
    </el-form>

    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column label="ID" width="60px">
        <template #default="scope">
          <span>{{ scope.row.ID }}</span>
        </template>
      </el-table-column>
      <el-table-column label="阶梯" width="120px">
        <template #default="scope">
          <span>{{ scope.row.step }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下限(m³)" width="80px">
        <template #default="scope">
          <span>{{ scope.row.lowLimit }}</span>
        </template>
      </el-table-column>
      <el-table-column label="上限(m³)" width="80px">
        <template #default="scope">
          <span>{{ scope.row.highLimit }}</span>
        </template>
      </el-table-column>
      <el-table-column label="单价(¥)" width="80px">
        <template #default="scope">
          <span>{{ scope.row.waterRate }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" width="180px">
        <template #default="scope">
          <span>{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" min-width="120">
        <template #default="scope">
          <el-button
            type="primary"
            :icon="Edit"
            size="small"
            @click="handleEdit(scope.$index, scope.row)"
          />

          <el-button
            size="small"
            type="danger"
            :icon="Delete"
            @click="handleDelete(scope.$index, scope.row)"
          >
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <p></p>
    <el-pagination background layout="prev, pager, next" :total="100" />
  </el-main>
</template>

<script lang="ts" setup>
import { reactive } from "vue";
import { Phone, Timer } from "@element-plus/icons-vue";
import { ref } from "vue";
import { Delete, Edit, Search, Upload, Plus } from "@element-plus/icons-vue";
import { Document, Menu as IconMenu, Location, Setting } from "@element-plus/icons-vue";

const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
const activeIndex = ref("1");
const activeIndex2 = ref("1");
const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
interface User {
  ID: number;
  step: string;
  lowLimit: string;
  highLimit: string;
  waterRate: string;
  createTime: string;
}

const handleEdit = (index: number, row: User) => {
  console.log(index, row);
};
const handleDelete = (index: number, row: User) => {
  console.log(index, row);
};

const tableData: User[] = [
  {
    ID: 1,
    step: "第一阶梯",
    lowLimit: "1",
    highLimit: "20",
    waterRate: "12",
    createTime: "2016-05-02 22:08:08",
  },
  {
    ID: 1,
    step: "第一阶梯",
    lowLimit: "1",
    highLimit: "20",
    waterRate: "12",
    createTime: "2016-05-02 22:08:08",
  },
  {
    ID: 1,
    step: "第一阶梯",
    lowLimit: "1",
    highLimit: "20",
    waterRate: "12",
    createTime: "2016-05-02 22:08:08",
  },
];
const formInline = reactive({
  user: "",
  region: "",
  date: "",
});

const onSubmit = () => {
  console.log("submit!");
};
</script>

<style>
.demo-form-inline .el-input {
  --el-input-width: 220px;
}

.demo-form-inline .el-select {
  --el-select-width: 220px;
}
</style>
